home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / pack / ppdecrypt / ppdecrypt.s < prev    next >
Text File  |  1980-01-03  |  36KB  |  1,552 lines

  1. *******************************************************************************
  2. * PowerPacker [ENCRYPTED EXECUTABLE] Cracker/Decryptor v1.02
  3. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  4. * $Release    : 0.1 $
  5. * $Revision    : 1.02 $
  6. * $Date        : 20-Sep-94 $
  7. *
  8. * $Author(s)    : Written by 2-Cool/LSd! (In MC680x0 Assembly under Asm-One)
  9. * $Note(s)    : Position Independacy off a4 - (WARNING: DON`T TRASH A4!)
  10. *        : Execbase Ptr is cached so that if running in fastmem access
  11. *        : to execbase ptr is faster.
  12. *
  13. * $Purpose    : This program cracks wide open the protection on PowerPacker
  14. *        : executables encrypted with a password. PowerPacker has some
  15. *        : main fundemental flaws in its encryption, suffice to say 
  16. *        : this program can decrypt the passwords with ease in seconds,
  17. *        : not days or months!
  18. *        :
  19. *        : The program will decrypt the original protection code then
  20. *        : re-encrypt it with the password 'lsd' (Make sure you enter
  21. *        : it in LOWERCASE not UPPER!) This is only required if you 
  22. *        : wish to unpack it with PowerPacker to return it to its 
  23. *        : original unpacked state since the decrunch header is modified
  24. *        : to automatically enter the password for you so it will run 
  25. *        : without any password prompts!
  26. *        :
  27. *        : Note to author of PowerPacker: Nico, PowerPacker`s encryption
  28. *        : is totally lame, take a loooong look at PGP and LEARN!
  29. *******************************************************************************
  30. AbsExecBase    =    4            /* Execbase Definition */
  31. SUCCESS        =    0            /* result return codes... */
  32. VAR_ERROR    =    1            /* memory alloction failcode */
  33. CSI        =    $1b
  34. hunk_unit    =    $3e7
  35. hunk_name    =    $3e8
  36. hunk_code    =    $3e9
  37. hunk_data    =    $3ea
  38. hunk_bss    =    $3eb
  39. hunk_reloc32    =    $3ec
  40. hunk_reloc16    =    $3ed
  41. hunk_reloc8    =    $3ee
  42. hunk_ext    =    $3ef
  43. hunk_symbol    =    $3f0
  44. hunk_debug    =    $3f1
  45. hunk_end    =    $3f2
  46. hunk_header    =    $3f3
  47. hunk_overlay    =    $3f5
  48. hunk_break    =    $3f6
  49. CLS        macro
  50.         dc.b    CSI,'c',LF
  51.         endm
  52. _LVORawIOInit    =    -$1F8
  53.         
  54. *-------------- Definition Includes...
  55.  
  56.         incdir    _include:
  57.         include    exec/exec.i
  58.         include    "include:exec/funcdef.i"
  59.         include    intuition/intuition.i
  60.         include    graphics/videocontrol.i
  61.         include    libraries/asl.i
  62.         include    libraries/gadtools.i
  63.         include    libraries/dos_lib.i
  64.         include    libraries/intuition_lib.i
  65.         include    libraries/graphics_lib.i
  66.         include    libraries/exec_lib.i
  67.         include    libraries/asl_lib.i
  68.         include    libraries/icon_lib.i
  69.         include    libraries/diskfont_lib.i
  70.         include    libraries/gadtools_lib.i
  71.         include    libraries/wb_lib.i
  72.         include    libraries/rexxsyslib_lib.i
  73.         include    libraries/utility_lib.i
  74.         include    libraries/dosextens.i
  75.         include    utility/tagitem.i
  76.         include    dos/datetime.i
  77.         include    libraries/reqtools.i
  78.         
  79. *-------------- Definition of Main Variables (Public) Block...
  80.  
  81.         STRUCTURE VarsBlock,0
  82.  
  83.         APTR    _ExecBase            /* ExecBase base */
  84.         APTR    _DOSBase            /* DOS lib base */
  85.         APTR    _DOSOutput            /* DOS output base */
  86.         APTR    _ArgPtr                /* CLI Args ptr */
  87.         ULONG    _ArgLen                /* CLI Args length */
  88.         APTR    _AslBase            /* Asl lib base */
  89.         APTR    _Asl_Request            /* Requester struct */
  90.         APTR    _PrtfBase            /* Printf fmstr base */
  91.         APTR    ProgBuff            /* ptr to progbuffer */
  92.         APTR    ProgHandle            /* ptr to filehandle */
  93.         ULONG    ProgSize            /* length file */
  94.         APTR    FilePath.arg            /* argstream pathptr */
  95.         STRUCT    _PathBuffer,256            /* path buffer */
  96.  
  97.         APTR    DecBuff                /* Decrunch Buff Ptr */
  98.         ULONG    DecSize                /* Decrunch Buff size */
  99.  
  100.         LABEL    vars_SIZEOF
  101.  
  102. *-------------- Definition of Macros...
  103.  
  104. PUSH        macro
  105.         movem.l    \1,-(sp)
  106.         endm
  107. PULL        macro
  108.         movem.l    (sp)+,\1
  109.         endm
  110. PUSHW        macro
  111.         movem.w    \1,-(sp)
  112.         endm
  113. PULLW        macro
  114.         movem.w    (sp)+,\1
  115.         endm
  116. PUSHR        macro
  117.         move.l    \1,-(sp)
  118.         endm
  119. PULLR        macro
  120.         move.l    (sp)+,\1
  121.         endm
  122. CALL        macro
  123.         jsr    _LVO\1(a6)
  124.         endm
  125. CALLJ        macro
  126.         jmp    _LVO\1(a6)
  127.         endm
  128. CALLREL        macro
  129.         move.l    \2(a4),a6
  130.         CALL    \1
  131.         endm
  132.         
  133. *******************************************************************************
  134. *-------------- Allocate our Variables (RS.) Area
  135.  
  136. ProgStart:    move.l    a0,a5
  137.         move.l    d0,d5
  138.  
  139.         move.l    #vars_SIZEOF,d0        ;length for our variables
  140.         move.l    #MEMF_PUBLIC+MEMF_CLEAR,d1 ;we want public mem, cleared
  141.         move.l    (AbsExecBase).w,a6    ;get SysBase
  142.         CALL    AllocMem        ;allocate it...
  143.         move.l    d0,a4            ;ptr to our RS.Variables base
  144.         bne.s    RSValid            ;did the alloc fail, if so exit
  145.         moveq    #VAR_ERROR,d0        ;Memory allocation fail code
  146.         rts                ;exit to dos...
  147.  
  148. *-------------- Place Version String here so it can be quickly found.
  149.  
  150. Version:    dc.b    "$VER: PPDecrypt v1.02 (Sep-94)",0
  151.         even
  152.  
  153. *-------------- From here a4 points to our variables area (DON`T DESTROY A4!)
  154.  
  155. RSValid:    move.l    a6,(a4)            ;cache execptr in Public so if
  156.                         ;we are in fastmem were faster
  157.         move.l    a5,_ArgPtr(a4)
  158.         move.l    d5,_ArgLen(a4)
  159.         clr.b    -1(a5,d5.w)        ;null terminate arg string..
  160.  
  161. *-------------- Open DOS Library
  162.  
  163.         moveq    #36,d0            ;set lib version
  164.           lea    Dosname(pc),a1        ;lib name in a1
  165.           CALL    OpenLibrary        ;try to open library
  166.           move.l    d0,_DOSBase(a4)        ;store lib base
  167.           beq.w    ShutDown        ;cleanup and quit if fail
  168.  
  169. *-------------- Get DOS Output
  170.  
  171.         move.l    d0,a6            ;get dosbase
  172.         CALL    Output            ;get output base
  173.         move.l    d0,_DOSOutput(a4)    ;save outputbase
  174.  
  175. *-------------- Open ASL Library
  176.  
  177.         move.l    (a4),a6            ;get execbase
  178.         moveq    #36,d0            ;set lib version
  179.           lea    Aslname(pc),a1        ;lib name in a1
  180.           CALL    OpenLibrary        ;try to open library
  181.           move.l    d0,_AslBase(a4)        ;store lib base
  182.           beq.w    ASLError        ;cleanup and quit if fail
  183.  
  184. *-------------- Allocate ASL Requester
  185.  
  186.         move.l    d0,a6            ;get asl base in a6
  187.         moveq    #ASL_FileRequest,d0    ;requester type
  188.         lea    MainTags(pc),a0        ;taglist
  189.         CALL    AllocAslRequest        ;allocate asl request struct
  190.         move.l    d0,_Asl_Request(a4)    ;save request struct
  191.           beq.w    AllocError        ;show 'out of memory' msg
  192.  
  193. *-------------- Initialise 'printf' routines...
  194.  
  195.         bsr.w    _PrintInit        ;initialise printf memory
  196.           beq.w    AllocError        ;show 'out of memory' msg
  197.  
  198. *-------------- Program starts here
  199.  
  200.         lea    About.Txt(pc),a0        ;format string
  201.         bsr.w    PutStr
  202.  
  203. *-------------- Show usage message or request a filename?
  204.  
  205.         move.l    _ArgPtr(a4),a0
  206.         cmp.b    #"?",(a0)
  207.         beq.s    show_usage
  208.         cmp.b    #LF,(a0)
  209.         beq.s    no_filename
  210.         tst.b    (a0)
  211.         beq.s    no_filename
  212.         bra.s    ShowFName
  213.  
  214. show_usage:    lea    Args.Txt(pc),a0        ;format string
  215.         bsr.w    PutStr
  216.         bra.w    ShutDown
  217.     
  218. *-------------- Example ASL Requester 'LOAD'
  219.  
  220. no_filename:    lea    Select.Txt(pc),a0    ;format string
  221.         bsr.w    PutStr
  222.  
  223. ;-------------- Example ASL Requester 'LOAD'
  224.  
  225.         lea    LoadTags(pc),a1        ;address of taglist
  226.         lea    LoadText(pc),a2        ;ptr to requester hail text
  227.         bsr.w    RequestASL
  228.         beq.w    NoName            ;load 'express failed'
  229.     
  230. ShowFName:    move.l    a0,-(sp)
  231.         lea    FilePath.arg(a4),a1    ;arguments stream
  232.         move.l    a0,(a1)            ;pathname into arg stream
  233.         lea    FilePath.fmt(pc),a0    ;format string
  234.         bsr.w    printf
  235.         move.l    (sp)+,a0        ;a0=filename ptr
  236.  
  237. *-------------- Load DOS file into buffer
  238.  
  239.         bsr.w    LoadDOSFile
  240.         cmp.b    #-2,d0
  241.         beq.w    LoadFailedMem        ;load 'express failed'
  242.         cmp.b    #-1,d0
  243.         beq.w    LoadNotFound
  244.  
  245. *-------------- Now do the processing bits here...
  246.  
  247.         move.l    ProgBuff(a4),a0        
  248.         move.l    ProgSize(a4),d0
  249.         bsr    ProcessData
  250.         beq.s    dosave            ;was it successful?
  251.  
  252.         lea    ErrorType.txt(pc),a0
  253.         bsr    PutStr
  254.         bra.s    ShutDown
  255.         
  256. *-------------- Example ASL Requester 'SAVE'
  257.  
  258. dosave:        lea    Done.Txt(pc),a0        ;format string
  259.         move.b    PatchType(pc),d0
  260.         beq.s    normal_hd
  261.         lea    Done2.Txt(pc),a0    ;format string
  262. normal_hd    bsr.w    PutStr
  263.  
  264.         lea    SaveTags(pc),a1        ;address of taglist
  265.         lea    SaveText(pc),a2        ;ptr to requester hail text
  266.         bsr.w    RequestASL
  267.         beq.w    NoName
  268.  
  269.         move.l    a0,-(sp)
  270.         lea    FilePath.arg(a4),a1    ;arguments stream
  271.         move.l    a0,(a1)            ;pathname into arg stream
  272.         lea    FilePath2.fmt(pc),a0    ;format string
  273.         bsr.w    printf
  274.         move.l    (sp)+,a0        ;a1=name of file to save
  275.  
  276.         bsr.w    SaveDOSFile        ;save out the file!!!
  277.  
  278. *-------------- Free decrunch memory buffer...
  279.  
  280.         move.l    d0,-(sp)
  281.         move.l    DecBuff(a4),d0        ;ptr to our RS.Variables base
  282.         beq.s    no_decmem
  283.         move.l    d0,a1        
  284.         move.l    DecSize(a4),d0        ;no. of bytes to free
  285.         beq.s    no_decmem
  286.         move.l    (a4),a6            ;get execbase
  287.         CALL    FreeMem            ;free the memory
  288. no_decmem    move.l    (sp)+,d0
  289.  
  290.         cmp.b    #1,d0
  291.         beq.b    SaveError
  292.  
  293. *-------------- Program ends here
  294.  
  295. *******************************************************************************
  296. * Shutdown() - Free all allocated resources & exit program
  297. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  298. * Frees all previously allocated resources, sanity checks are made so only
  299. * allocated memory/open libraries will be removed.
  300. *******************************************************************************
  301.  
  302. ShutDown:    bsr.w    FreeDOSFile
  303.  
  304. *-------------- Free 'printf' memory
  305.  
  306.         bsr.w    _PrintClose        ;free printf memory
  307.  
  308. *-------------- Free Allocated ASL File-Requester
  309.  
  310.         move.l    _Asl_Request(a4),d0    ;get request struct
  311.         beq.s    FreeASL    
  312.         move.l    d0,a0
  313.         move.l    _AslBase(a4),a6
  314.         CALL    FreeAslRequest
  315.  
  316. *-------------- Free ASL Library
  317.  
  318. FreeASL:    move.l    (a4),a6            ;get execbase
  319.         move.l    _AslBase(a4),d0        ;asl lib base in a1
  320.         beq.s    FreeDOS
  321.         move.l    d0,a1
  322.          CALL    CloseLibrary        ;close asl
  323.  
  324. *-------------- Free DOS Library
  325.  
  326. FreeDOS:    move.l    _DOSBase(a4),d0        ;dos lib base in a1
  327.         beq.s    RSFreeMem
  328.         move.l    d0,a1
  329.           CALL    CloseLibrary        ;close intuition
  330.         clr.l    _DOSBase(a4)        ;clear out base
  331.         
  332. *-------------- Free RS Variables Area
  333.  
  334. RSFreeMem:    move.l    a4,a1            ;ptr to our RS.Variables base
  335.         move.l    #vars_SIZEOF,d0        ;no. of bytes to free
  336.         move.l    (a4),a6            ;get execbase
  337.         CALL    FreeMem            ;free the memory
  338.  
  339.         moveq    #SUCCESS,d0        ;no return code
  340.         rts                ;exit...
  341.  
  342. AllocError:    lea    ErrorAlloc.txt(pc),a0
  343.         bra.s    showmsg
  344. LoadFailedMem    lea    ErrorMem.txt(pc),a0
  345.         bra.s    showmsg
  346. LoadNotFound    lea    ErrorLoad.txt(pc),a0
  347.         bra.s    showmsg
  348. SaveError    lea    ErrorSave.txt(pc),a0
  349.         bra.s    showmsg
  350. ASLError    lea    ErrorASL.txt(pc),a0
  351.         bra.s    showmsg
  352. NoName        lea    NoName.txt(pc),a0
  353. showmsg        bsr.w    PutStr
  354.         bra.s    ShutDown
  355.  
  356. *******************************************************************************
  357. * PowerPacker HUNK Scanner
  358. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  359. * Firstly we need to scan through the code & data hunks to get the correct 
  360. * addresses of the packed data, the pack_data info and the unpacking code and
  361. * password prompting code...
  362. *******************************************************************************
  363.  
  364. ProcessData:    cmp.l    #hunk_header,(a0)+    ; must start with a hunk_header
  365.         bne.w    reloc_error        ; if not we`ve got problems!
  366.         tst.l    (a0)+            ; if its named, skip name
  367.         bne.w    reloc_error        ; if 0 its alright!
  368.  
  369.         move.l    (a0)+,d7        ; read no. hunks from LoadBuffer
  370.         move.l    d7,d6            ; d6=copy of no.hunks...
  371.         add.l    d7,d7
  372.         add.l    d7,d7
  373.         add.l    d7,d7            ; 2 long words per hunk
  374.  
  375.         sub.l    d7,sp
  376.         addq.w    #8,a0            ; skip first/last hunk nos
  377.         move.l    sp,a1
  378.         move.l    sp,a5
  379.  
  380. hunksetuplp    move.l    (a0)+,d0        ; get hunk length
  381.         add.l    d0,d0
  382.         add.l    d0,d0            ; x4 Get address from BCPL ptr
  383.         addq.l    #8,a3            ; add segment header
  384.         add.l    d0,a3
  385.         subq.l    #1,d6
  386.         bne.s    hunksetuplp
  387.         move.l    d7,d0            ; zero count+8 bytes per hunk
  388.  
  389. hunksumlp    add.l    (sp)+,d0        ; add lengths etc.
  390.         addq.l    #4,sp            ; recover stack at same time!
  391.         subq.l    #8,d7
  392.         bne.s    hunksumlp
  393.  
  394. relocok        cmp.l    #hunk_code,(a0)+    ; hope we got a code_hunk..
  395.         bne.w    reloc_error
  396.         move.l    (a0)+,d0
  397.  
  398. GetHeaderType:    movem.l    d0-d7/a0-a6,-(sp)
  399.         lea    WorkingN.Txt(pc),a1    ;format string
  400.         sf.b    PatchType-WorkingN.Txt(a1)
  401.         cmp.l    #$0c05000d,$5a(a0)    ;\    Check thats its really
  402.         bne.w    notreallypp        ; \   a PowerPacker encrypted
  403.         cmp.w    #$b998,$90(a0)        ;  \_ executable file..
  404.         beq.w    not_big
  405.  
  406. notreallypp:    lea    WorkingH.Txt(pc),a1    ;format string
  407.         st.b    PatchType-WorkingH.Txt(a1)
  408.         cmp.w    #$4EaE,$30(a0)
  409.         bne.w    reloc_error
  410.  
  411. not_big        move.l    a1,a0
  412.         bsr.w    PutStr
  413.         movem.l    (sp)+,d0-d7/a0-a6
  414.  
  415.         move.l    a0,a3
  416.         move.l    a0,-(sp)
  417.         add.l    d0,d0
  418.         add.l    d0,d0
  419.         add.l    d0,a0
  420.         move.l    a0,a1
  421.         lea    8(a1),a1
  422.         move.l    (a1)+,d0
  423.         add.l    d0,d0
  424.         add.l    d0,d0
  425.         add.l    d0,a1            ;end of hunk
  426.  
  427.         lea    12(a0),a6        ;a6.l = PP SrcData Start Ptr
  428.  
  429. *-------------- Offset for for normal header files
  430.         lea    -10(a0),a5        ;a5.l = PP Data Info
  431.         move.b    PatchType(pc),d0
  432.         beq.s    not_header
  433.  
  434. *-------------- Offset for Library Header files
  435.         lea    -12(a0),a5        ;a5.l = PP Data Info
  436. not_header
  437.  
  438.         move.l    4(a5),d0        ;Original Length
  439.  
  440.         bsr    find_cmode
  441.         
  442.         move.l    a1,a2
  443.         sub.l    a0,a2
  444.         lea    -16(a2),a2
  445.         move.l    a2,d6
  446.         move.l    d6,d7
  447.         lsr.l    #2,d6
  448.         subq.l    #1,d6            ; decrypt length (for dbra)
  449.  
  450. *-------------- PowerPacker DECRYPTOR (PASS - 1)
  451. *        Determine the 1st 3 bytes of the Longword password...
  452. *
  453. *        We do this by checking against the ~magic~ numbers, $xx16785C
  454. *        or $xx2cf0b8 which will always be present in normal 
  455. *        (non-encrypted) PowerPacked executables. This number is the 
  456. *        PowerPacked (crunched) equivelent '$000003F2 $0000000' Standard
  457. *        DOSExecutable hunk header, Therefore when we 'un-eor' the 1st 4
  458. *        bytes of the packed data with the correct un-eor value we KNOW
  459. *        we have obtained the 1st 3 bytes of the password!
  460.  
  461.         lea    DecryptLoop(pc),a2
  462.         moveq    #0,d4        
  463.         move.l    (a6),d1            ;d1=$xxxx xxxx to un-eor
  464.         move.l    #$00ffffff,d5
  465.                         
  466. DecryptLoop:    eor.l    d4,d1
  467.         move.l    d1,d3
  468.         and.l    d5,d3
  469.         cmp.l    d2,d3
  470.         beq.s    cracked_it
  471.         eor.l    d4,d1
  472.         addq.l    #1,d4            ;next try
  473.         jmp    (a2)
  474.  
  475. *-------------- PowerPacker DECRYPTOR (PASS - 2)
  476. *        Determine the last bytes of the Longword password...
  477.  
  478. cracked_it:    movem.l    d0-d7/a0-a6,-(sp)
  479.         lea    Pass2.Txt(pc),a0    ;format string
  480.         bsr.w    PutStr
  481.         movem.l    (sp)+,d0-d7/a0-a6
  482.         move.l    a1,a0
  483.         
  484.         movem.l    d4-d7/a0-a6,-(sp)
  485.         add.l    #10000,d0        ;Unpacked size + 10k
  486.         move.l    d0,DecSize(a4)        ;save original alloc size
  487.         move.l    #MEMF_PUBLIC+MEMF_CLEAR,d1 ;we want public mem, cleared
  488.         move.l    (AbsExecBase).w,a6    ;get SysBase
  489.         CALL    AllocMem        ;allocate it...
  490.         movem.l    (sp)+,d4-d7/a0-a6
  491.         move.l    d0,DecBuff(a4)        ;save decrunch buffer Ptr
  492.         bne.s    alloc_okay
  493.  
  494.         tst.l    (sp)+            ;correct stack...
  495.         bra.w    AllocError
  496.  
  497. alloc_okay:    move.l    d0,a3            ;ptr to dest mem
  498.         lea    5000(a3),a3        ;+5k minimum safe distance
  499.                         ;on either side..
  500.         move.l    #$000003f3,d5
  501.         move.l    #$01000000,d3
  502.  
  503. ;d0.l = Original Unpacked Length..
  504. ;d4.l = EOR Value (excluding high byte) $??XXXXXX
  505. ;d6.l = EOR Decrypt Size
  506. ;
  507. ;a0.l = PP_SrcData End
  508. ;a3.l = Unpacked Destination
  509. ;a5.l = PP_SrcData Info
  510. ;a6.l = PP_SrcData Start
  511. ;
  512. *-------------- decrypt with current EOR Value..
  513.  
  514. DecLoop:    move.l    a6,a2
  515.         move.l    d6,d1
  516. .un_eor:    eor.l    d4,(a2)+
  517.         dbra    d1,.un_eor
  518.  
  519. *-------------- now attempt uncompression
  520.         
  521.         movem.l    d0/d3-d7/a0-a6,-(sp)
  522.         bsr    PPDecrunch
  523.         movem.l    (sp)+,d0/d3-d7/a0-a6
  524.         move.l    a0,-(sp)
  525.         lea    Dot.Txt(pc),a0
  526.         bsr    PutStr
  527.         move.l    (sp)+,a0
  528.         
  529.         cmp.l    (a3),d5
  530.         beq.s    valid
  531.  
  532. *-------------- was the wrong eor value, so return it to normal..
  533.  
  534.         move.l    a6,a2
  535.         move.l    d6,d1
  536. .re_eor:    eor.l    d4,(a2)+
  537.         dbra    d1,.re_eor
  538.  
  539.         add.l    d3,d4
  540.         move.l    d4,d1
  541.         and.l    #$ff000000,d1
  542.         bne.s    DecLoop
  543.         addq.l    #1,d4
  544.  
  545.         move.l    a0,-(sp)
  546.         lea    Deep.Txt(pc),a0
  547.         bsr    PutStr
  548.         move.l    (sp)+,a0
  549.  
  550.         bra.s    DecLoop
  551.  
  552.  
  553.  
  554. valid:
  555. ;a0.l = PP_SrcData End
  556. ;a3.l = Unpacked File Ptr
  557. ;d0.l = Unpacked Length
  558.  
  559.         move.l    (sp)+,a1
  560.  
  561.         move.l    a6,a2
  562.         move.l    d6,d1
  563. tmp        move.l    #$021400e6,d4
  564. .re_eor:    eor.l    d4,(a2)+
  565.         dbra    d1,.re_eor
  566.  
  567.         move.b    PatchType(pc),d0
  568.         bne.s    header_ppdata2
  569.  
  570.         move.w    BR(pc),$0C(a1)
  571.         move.l    d4,$7A(a1)
  572.         move.w    tmp(pc),$78(a1)
  573.         move.w    #$086c,$6a(a1)        ;patch password checksum in normal header
  574.         bra.w    not_header2
  575.  
  576. header_ppdata2:    move.w    #$086c,$26(a1)        ;patch password checksum in library header
  577.  
  578. not_header2:    addq.l    #4,a0
  579.         move.l    ProgBuff(a4),a1
  580.         move.l    a1,d0
  581.         sub.l    a1,d0
  582.         move.l    tempptr(pc),a2
  583.         move.l    temp(pc),(a2)
  584.  
  585. *-------------- ALL DONE! We`ve 100% cracked it when we get to here!
  586.  
  587. ;now just the saving out...
  588.  
  589. ;a1.l = Adr of Code save
  590. ;d0.l = Length of Code to save
  591.  
  592.         moveq    #0,d1        ;decryption successful
  593.         rts
  594. reloc_error:    moveq    #-1,d1
  595.         rts
  596.  
  597. BR:        bra.s    *+$72-6
  598. temp        dc.l    0
  599. tempptr        dc.l    0
  600. PatchType:    dc.w    0        
  601.  
  602. find_cmode:    movem.l    d0-d1/d3-d7/a0-a6,-(sp)
  603.  
  604.         move.l    (a5),d1            ;d1=mode used (hex)
  605. check_fast:    cmp.l    #$090a0c0d,d1
  606.         bne.s    not_best
  607.         lea    Best.Txt(pc),a0
  608.         bsr    PutStr
  609.         move.l    #$0016785C,d2        ;best
  610.         bra.s    got_mode
  611.  
  612. not_best:    cmp.l    #$090a0c0c,d1
  613.         bne.s    not_vgood
  614.         lea    VGood.Txt(pc),a0
  615.         bsr    PutStr
  616.         move.l    #$0016785C,d2        ;very good
  617.         bra.s    got_mode
  618.  
  619. not_vgood:    cmp.l    #$090a0b0b,d1
  620.         bne.s    not_good
  621.         lea    Good.Txt(pc),a0
  622.         bsr    PutStr
  623.         move.l    #$0016785C,d2        ;good
  624.         bra.s    got_mode
  625.  
  626. not_good:    cmp.l    #$090a0a0a,d1
  627.         bne.s    not_mediocre
  628.         lea    Mediocre.Txt(pc),a0
  629.         bsr    PutStr
  630.         move.l    #$0016785C,d2        ;mediocre
  631.         bra.s    got_mode
  632.  
  633. not_mediocre:    cmp.l    #$09090909,d1
  634.         bne.s    unknown_mode
  635.         lea    Fast.Txt(pc),a0
  636.         bsr    PutStr
  637.         move.l    #$002CF0B8,d2        ;fast
  638.         bra.s    got_mode
  639.  
  640. unknown_mode:    lea    Unknown.Txt(pc),a0
  641.         bsr    PutStr
  642. got_mode:    lea    Length.Txt(pc),a0
  643.         bsr    PutStr
  644.         ;d0.l = Original Length
  645.         move.l    d2,-(sp)
  646.         bsr    H2A
  647.         move.l    (sp)+,d2
  648.  
  649.         movem.l    (sp)+,d0-d1/d3-d7/a0-a6
  650.         rts
  651.  
  652. H2A:        lea    Value.txt(pc),a0
  653. Hex2ASCIIDec:    lea    hextable(pc),a1
  654.         move.b    #"0",d6            ; constant
  655.         move.b    #" ",d5            ; replace leading 0's
  656.         moveq    #9-1,d4
  657. ccloop        move.l    (a1)+,d1
  658.         cmp.l    d1,d0
  659.         bcs.s    get3
  660.          move.w    #32-1,d3
  661.         moveq    #0,d2
  662. get1        add.l    d0,d0
  663.         roxl.l    #1,d2
  664.         cmp.l    d1,d2
  665.         bcs.s    get2
  666.         sub.l    d1,d2
  667.         addq.l    #1,d0
  668. get2        dbra    d3,get1
  669.         add.b    d6,d0
  670.         move.b    d0,(a0)+
  671.         move.l    d2,d0
  672.         move.b    d6,d5
  673.         bra.s    get4
  674.  
  675. get3        move.b    d5,(a0)+
  676. get4        dbra    d4,ccloop
  677.          add.b    d6,d0
  678.         move.b    d0,(a0)+
  679.         lea    Value.txt(pc),a0
  680. .getstart    cmp.b    #" ",(a0)+
  681.         beq.s    .getstart
  682.         tst.b    -(a0)
  683.         bsr    PutStr
  684.         lea    LFs.Txt(pc),a0
  685.         bra    PutStr
  686.  
  687. hextable    dc.l    1000000000
  688.         dc.l    100000000
  689.         dc.l    10000000
  690.         dc.l    1000000
  691.         dc.l    100000
  692.         dc.l    10000
  693.         dc.l    1000
  694.         dc.l    100
  695.         dc.l    10
  696.         dc.l    1
  697.         dc.l    0
  698.  
  699. *******************************************************************************
  700. * PowerPacker FAST-Decruncher
  701. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  702. *******************************************************************************
  703.  
  704. PPDecrunch:    move.l    a3,a1
  705.         lea    -4(a6),a2
  706.         move.l    (a5),d0
  707.         lea    PPB_24E(pc),a5
  708.         tst.l    tempptr-PPB_24E(a5)
  709.         bne.s    is_set
  710.         move.l    a2,tempptr-PPB_24E(a5)
  711.         move.l    (a2),temp-PPB_24E(a5)
  712.  
  713. is_set:        move.l    d0,(a2)
  714.         moveq    #$18,d6
  715.         moveq    #0,d4
  716.         moveq    #1,d5
  717.         move.l    d5,d7
  718.  
  719.         move.l    a1,a4
  720.         move.l    -(a0),d1
  721.         move.l    d1,-(sp)        ;save unpacked length
  722.  
  723.         tst.b    d1
  724.         beq.s    PP_22
  725.         lsr.l    d7,d5
  726.         beq.s    PP_5E
  727. PP_1E:        sub.b    d7,d1
  728.         lsr.l    d1,d5
  729. PP_22:        lsr.l    #8,d1
  730.         add.l    d1,a1
  731. PP_26:        lsr.l    d7,d5
  732.         beq.s    PP_64
  733. PP_2A:        bcs    PP_CC
  734.         moveq    #0,d2
  735. PP_30:        moveq    #0,d1
  736.         lsr.l    d7,d5
  737.         beq.s    PP_6A
  738. PP_36:        roxl.w    d7,d1
  739.         lsr.l    d7,d5
  740.         beq.s    PP_70
  741. PP_3C:        roxl.w    d7,d1
  742.         add.w    d1,d2
  743.         subq.w    #3,d1
  744.         beq.s    PP_30
  745.         moveq    #0,d0
  746. PP_46:        move.b    d5,d4
  747.         lsr.l    #8,d5
  748.         beq.s    PP_82
  749. PP_4C:        move.b    -$80(a5,d4.w),d0
  750.         move.b    d0,-(a1)
  751.         dbra    d2,PP_46
  752.         cmp.l    a1,a4
  753.         bcs.s    PP_CC
  754.         bra    PP_1AA
  755.  
  756. PP_5E:        move.l    -(a0),d5
  757.         roxr.l    d7,d5
  758.         bra.s    PP_1E
  759.  
  760. PP_64:        move.l    -(a0),d5
  761.         roxr.l    d7,d5
  762.         bra.s    PP_2A
  763.  
  764. PP_6A:        move.l    -(a0),d5
  765.         roxr.l    d7,d5
  766.         bra.s    PP_36
  767.  
  768. PP_70:        move.l    -(a0),d5
  769.         roxr.l    d7,d5
  770.         bra.s    PP_3C
  771.  
  772. PP_76:        move.l    -(a0),d5
  773.         roxr.l    d7,d5
  774.         bra.s    PP_D2
  775.  
  776. PP_7C:        move.l    -(a0),d5
  777.         roxr.l    d7,d5
  778.         bra.s    PP_D8
  779.  
  780. PP_82:        move.b    $7F(a5,d4.w),d0
  781.         move.l    -(a0),d5
  782.         move.w    d5,d3
  783.         lsl.w    d0,d3
  784.         bchg    d0,d3
  785.         eor.w    d3,d4
  786.         and.w    #$ff,d4
  787.         moveq    #8,d1
  788.         sub.w    d0,d1
  789.         lsr.l    d1,d5
  790.         add.w    d6,d0
  791.         bset    d0,d5
  792.         bra.s    PP_4C
  793.  
  794. PP_9E:        move.b    $7F(a5,d4.w),d0
  795.         move.l    -(a0),d5
  796.         move.w    d5,d3
  797.         lsl.w    d0,d3
  798.         bchg    d0,d3
  799.         eor.w    d3,d4
  800.         and.w    #$ff,d4
  801.         moveq    #8,d1
  802.         sub.w    d0,d1
  803.         lsr.l    d1,d5
  804.         add.w    d6,d0
  805.         bset    d0,d5
  806.         bra.s    PP_E0
  807.  
  808. PP_BA:        move.l    -(a0),d5
  809.         roxr.l    d7,d5
  810.         bra.s    PP_11A
  811.  
  812. PP_C0:        move.l    -(a0),d5
  813.         roxr.l    d7,d5
  814.         bra.s    PP_120
  815.  
  816. PP_C6:        move.l    -(a0),d5
  817.         roxr.l    d7,d5
  818.         bra.s    PP_126
  819.  
  820. PP_CC:        moveq    #0,d2
  821.         lsr.l    d7,d5
  822.         beq.s    PP_76
  823. PP_D2:        roxl.w    d7,d2
  824.         lsr.l    d7,d5
  825.         beq.s    PP_7C
  826. PP_D8:        roxl.w    d7,d2
  827.         move.b    d5,d4
  828.         lsr.l    #8,d5
  829.         beq.s    PP_9E
  830. PP_E0:        moveq    #0,d3
  831.         move.b    -$80(a5,d4.w),d3
  832.         cmp.w    #3,d2
  833.         bne.s    PP_168
  834.         bclr    #7,d3
  835.         beq.s    PP_13A
  836.         moveq    #13,d0
  837.         sub.b    (a2,d2.w),d0
  838.         move.w    d0,d1
  839.         add.w    d0,d0
  840.         add.w    d1,d0
  841.         add.w    d0,d0
  842.         jmp    PP_116(pc,d0.w)
  843.  
  844. PP_104:        move.l    -(a0),d5
  845.         roxr.l    d7,d5
  846.         bra.s    PP_12C
  847.  
  848. PP_10A:        move.l    -(a0),d5
  849.         roxr.l    d7,d5
  850.         bra.s    PP_132
  851.  
  852. PP_110:        move.l    -(a0),d5
  853.         roxr.l    d7,d5
  854.         bra.s    PP_138
  855.  
  856. PP_116:        lsr.l    d7,d5
  857.         beq.s    PP_BA
  858. PP_11A:        roxl.w    d7,d3
  859.         lsr.l    d7,d5
  860.         beq.s    PP_C0
  861. PP_120:        roxl.w    d7,d3
  862.         lsr.l    d7,d5
  863.         beq.s    PP_C6
  864. PP_126:        roxl.w    d7,d3
  865.         lsr.l    d7,d5
  866.         beq.s    PP_104
  867. PP_12C:        roxl.w    d7,d3
  868.         lsr.l    d7,d5
  869.         beq.s    PP_10A
  870. PP_132:        roxl.w    d7,d3
  871.         lsr.l    d7,d5
  872.         beq.s    PP_110
  873. PP_138:        roxl.w    d7,d3
  874. PP_13A:        moveq    #0,d1
  875.         lsr.l    d7,d5
  876.         beq.s    PP_156
  877. PP_140:        roxl.w    d7,d1
  878.         lsr.l    d7,d5
  879.         beq.s    PP_15C
  880. PP_146:        roxl.w    d7,d1
  881.         lsr.l    d7,d5
  882.         beq.s    PP_162
  883. PP_14C:        roxl.w    d7,d1
  884.         add.w    d1,d2
  885.         subq.w    #7,d1
  886.         beq.s    PP_13A
  887.         bra.s    PP_198
  888.  
  889. PP_156:        move.l    -(a0),d5
  890.         roxr.l    d7,d5
  891.         bra.s    PP_140
  892.  
  893. PP_15C:        move.l    -(a0),d5
  894.         roxr.l    d7,d5
  895.         bra.s    PP_146
  896.  
  897. PP_162:        move.l    -(a0),d5
  898.         roxr.l    d7,d5
  899.         bra.s    PP_14C
  900.  
  901. PP_168:        moveq    #13,d0
  902.         sub.b    (a2,d2.w),d0
  903.         move.w    d0,d1
  904.         add.w    d0,d0
  905.         add.w    d1,d0
  906.         add.w    d0,d0
  907.         jmp    PP_17A(pc,d0.w)
  908.  
  909. PP_17A:        lsr.l    d7,d5
  910.         beq.s    PP_1B0
  911. PP_17E:        roxl.w    d7,d3
  912.         lsr.l    d7,d5
  913.         beq.s    PP_1B6
  914. PP_184:        roxl.w    d7,d3
  915.         lsr.l    d7,d5
  916.         beq.s    PP_1BC
  917. PP_18A:        roxl.w    d7,d3
  918.         lsr.l    d7,d5
  919.         beq.s    PP_1C2
  920. PP_190:        roxl.w    d7,d3
  921.         lsr.l    d7,d5
  922.         beq.s    PP_1C8
  923. PP_196:        roxl.w    d7,d3
  924. PP_198:        move.b    (a1,d3.w),-(a1)
  925. PP_19C:        move.b    (a1,d3.w),-(a1)
  926.         dbra    d2,PP_19C
  927.         cmp.l    a1,a4
  928.         bcs    PP_26
  929. PP_1AA:        move.l    (sp)+,d0        ;d0=unpacked length
  930.         lsr.l    #8,d0            ;correct length
  931.         moveq    #0,d1            ;d1=result code = all ok!
  932.         rts
  933.  
  934. PP_1B0:        move.l    -(a0),d5
  935.         roxr.l    d7,d5
  936.         bra.s    PP_17E
  937.  
  938. PP_1B6:        move.l    -(a0),d5
  939.         roxr.l    d7,d5
  940.         bra.s    PP_184
  941.  
  942. PP_1BC:        move.l    -(a0),d5
  943.         roxr.l    d7,d5
  944.         bra.s    PP_18A
  945.  
  946. PP_1C2:        move.l    -(a0),d5
  947.         roxr.l    d7,d5
  948.         bra.s    PP_190
  949.  
  950. PP_1C8:        move.l    -(a0),d5
  951.         roxr.l    d7,d5
  952.         bra.s    PP_196
  953.     
  954.         or.l    #$40C020A0,d0
  955.         bra.s    PP_1B6
  956.  
  957.     dc.b    $10
  958.     dc.b    $90
  959.     dc.b    'P'
  960.     dc.b    $D0
  961.     dc.b    '0'
  962.     dc.b    $B0
  963.     dc.b    'p'
  964.     dc.b    $F0
  965.     dc.b    8
  966.     dc.b    $88
  967.     dc.b    'H'
  968.     dc.b    $C8
  969.     dc.b    '('
  970.     dc.b    $A8
  971.     dc.b    'h'
  972.     dc.b    $E8
  973.     dc.b    $18
  974.     dc.b    $98
  975.     dc.b    'X'
  976.     dc.b    $D8
  977.     dc.b    '8'
  978.     dc.b    $B8
  979.     dc.b    'x'
  980.     dc.b    $F8
  981.     dc.b    4
  982.     dc.b    $84
  983.     dc.b    'D'
  984.     dc.b    $C4
  985.     dc.b    '$'
  986.     dc.b    $A4
  987.     dc.b    'd'
  988.     dc.b    $E4
  989.     dc.b    $14
  990.     dc.b    $94
  991.     dc.b    'T'
  992.     dc.b    $D4
  993.     dc.b    '4'
  994.     dc.b    $B4
  995.     dc.b    't'
  996.     dc.b    $F4
  997.     dc.b    12
  998.     dc.b    $8C
  999.     dc.b    'L'
  1000.     dc.b    $CC
  1001.     dc.b    ','
  1002.     dc.b    $AC
  1003.     dc.b    'l'
  1004.     dc.b    $EC
  1005.     dc.b    $1C
  1006.     dc.b    $9C
  1007.     dc.b    '\'
  1008.     dc.b    $DC
  1009.     dc.b    '<'
  1010.     dc.b    $BC
  1011.     dc.b    '|'
  1012.     dc.b    $FC
  1013.     dc.b    2
  1014.     dc.b    $82
  1015.     dc.b    'B'
  1016.     dc.b    $C2
  1017.     dc.b    '"'
  1018.     dc.b    $A2
  1019.     dc.b    'b'
  1020.     dc.b    $E2
  1021.     dc.b    $12
  1022.     dc.b    $92
  1023.     dc.b    'R'
  1024.     dc.b    $D2
  1025.     dc.b    '2'
  1026.     dc.b    $B2
  1027.     dc.b    'r'
  1028.     dc.b    $F2
  1029.     dc.b    10
  1030.     dc.b    $8A
  1031.     dc.b    'J'
  1032.     dc.b    $CA
  1033.     dc.b    '*'
  1034.     dc.b    $AA
  1035.     dc.b    'j'
  1036.     dc.b    $EA
  1037.     dc.b    $1A
  1038.     dc.b    $9A
  1039.     dc.b    'Z'
  1040.     dc.b    $DA
  1041.     dc.b    ':'
  1042.     dc.b    $BA
  1043.     dc.b    'z'
  1044.     dc.b    $FA
  1045.     dc.b    6
  1046.     dc.b    $86
  1047.     dc.b    'F'
  1048.     dc.b    $C6
  1049.     dc.b    '&'
  1050.     dc.b    $A6
  1051.     dc.b    'f'
  1052.     dc.b    $E6
  1053.     dc.b    $16
  1054.     dc.b    $96
  1055.     dc.b    'V'
  1056.     dc.b    $D6
  1057.     dc.b    '6'
  1058.     dc.b    $B6
  1059.     dc.b    'v'
  1060.     dc.b    $F6
  1061.     dc.b    14
  1062.     dc.b    $8E
  1063.     dc.b    'N'
  1064.     dc.b    $CE
  1065.     dc.b    '.'
  1066.     dc.b    $AE
  1067.     dc.b    'n'
  1068.     dc.b    $EE
  1069.     dc.b    $1E
  1070.     dc.b    $9E
  1071.     dc.b    '^'
  1072.     dc.b    $DE
  1073.     dc.b    '>'
  1074.     dc.b    $BE
  1075.     dc.b    '~'
  1076.     dc.b    $FE
  1077. PPB_24E: dc.l    $18141C1
  1078.     dc.l    $21A161E1
  1079.     dc.l    $119151D1
  1080.     dc.l    $31B171F1
  1081.     dc.l    $98949C9
  1082.     dc.l    $29A969E9
  1083.     dc.l    $199959D9
  1084.     dc.l    $39B979F9
  1085.     dc.l    $58545C5
  1086.     dc.l    $25A565E5
  1087.     dc.l    $159555D5
  1088.     dc.l    $35B575F5
  1089.     dc.l    $D8D4DCD
  1090.     dc.l    $2DAD6DED
  1091.     dc.l    $1D9D5DDD
  1092.     dc.l    $3DBD7DFD
  1093.     dc.l    $38343C3
  1094.     dc.l    $23A363E3
  1095.     dc.l    $139353D3
  1096.     dc.l    $33B373F3
  1097.     dc.l    $B8B4BCB
  1098.     dc.l    $2BAB6BEB
  1099.     dc.l    $1B9B5BDB
  1100.     dc.l    $3BBB7BFB
  1101.     dc.l    $78747C7
  1102.     dc.l    $27A767E7
  1103.     dc.l    $179757D7
  1104.     dc.l    $37B777F7
  1105.     dc.l    $F8F4FCF
  1106.     dc.l    $2FAF6FEF
  1107.     dc.l    $1F9F5FDF
  1108.     dc.l    $3FBF7FFF
  1109.     dc.l    $10102
  1110.     dc.l    $2020203
  1111.     dc.l    $3030303
  1112.     dc.l    $3030304
  1113.     dc.l    $4040404
  1114.     dc.l    $4040404
  1115.     dc.l    $4040404
  1116.     dc.l    $4040405
  1117.     dc.l    $5050505
  1118.     dc.l    $5050505
  1119.     dc.l    $5050505
  1120.     dc.l    $5050505
  1121.     dc.l    $5050505
  1122.     dc.l    $5050505
  1123.     dc.l    $5050505
  1124.     dc.l    $5050506
  1125.     dc.l    $6060606
  1126.     dc.l    $6060606
  1127.     dc.l    $6060606
  1128.     dc.l    $6060606
  1129.     dc.l    $6060606
  1130.     dc.l    $6060606
  1131.     dc.l    $6060606
  1132.     dc.l    $6060606
  1133.     dc.l    $6060606
  1134.     dc.l    $6060606
  1135.     dc.l    $6060606
  1136.     dc.l    $6060606
  1137.     dc.l    $6060606
  1138.     dc.l    $6060606
  1139.     dc.l    $6060606
  1140.     dc.l    $6060607
  1141.     dc.l    $7070707
  1142.     dc.l    $7070707
  1143.     dc.l    $7070707
  1144.     dc.l    $7070707
  1145.     dc.l    $7070707
  1146.     dc.l    $7070707
  1147.     dc.l    $7070707
  1148.     dc.l    $7070707
  1149.     dc.l    $7070707
  1150.     dc.l    $7070707
  1151.     dc.l    $7070707
  1152.     dc.l    $7070707
  1153.     dc.l    $7070707
  1154.     dc.l    $7070707
  1155.     dc.l    $7070707
  1156.     dc.l    $7070707
  1157.     dc.l    $7070707
  1158.     dc.l    $7070707
  1159.     dc.l    $7070707
  1160.     dc.l    $7070707
  1161.     dc.l    $7070707
  1162.     dc.l    $7070707
  1163.     dc.l    $7070707
  1164.     dc.l    $7070707
  1165.     dc.l    $7070707
  1166.     dc.l    $7070707
  1167.     dc.l    $7070707
  1168.     dc.l    $7070707
  1169.     dc.l    $7070707
  1170.     dc.l    $7070707
  1171.     dc.l    $7070707
  1172.     dc.l    $7070700
  1173.     dc.b    $27
  1174.     dc.b    $A7
  1175.         even
  1176.  
  1177. *******************************************************************************
  1178. * PutStr
  1179. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1180. * Sends a ascii text string to current console output
  1181. * $Inputs:    a0.l = String ptr (null terminated)
  1182. *******************************************************************************
  1183.  
  1184. PutStr:        movem.l    d0-d7/a1-a6,-(sp)
  1185.         move.l    a0,d2
  1186.         moveq    #-1,d3            ;d4=0
  1187. .getlen2    addq.l    #1,d3            ;increase string length by 1
  1188.         tst.b    (a0)+            ;increase position
  1189.         bne.s    .getlen2        ;nope not found, so keep on
  1190.  
  1191.         move.l    _DOSOutput(a4),d1
  1192.         move.l    _DOSBase(a4),a6
  1193.         jsr    _LVOWrite(a6)        ;print error msg to cli
  1194.         movem.l    (sp)+,d0-d7/a1-a6
  1195.         rts
  1196.         
  1197. *******************************************************************************
  1198. * RequestASL <NON MODIFIABLE>
  1199. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1200. * Prompts user to select a filename using the ASL Requester
  1201. *
  1202. * $Inputs    : a1.l=Requester Tag Structure (PTR)
  1203. *        : a2.l=Requester Hail Text-String (PTR)
  1204. * $Outputs    : a0.l=Pathname of selected file, or Points to ZERO if failed
  1205. *        : d0.b=Flags 0,cancelled, -1,selected
  1206. *
  1207. * $SR-Flags    : Z-Flag Set if requester cancelled.
  1208. *******************************************************************************
  1209.  
  1210. RequestASL:    move.l    a2,4(a1)        ;hail textptr into tag struct
  1211.         move.l    _Asl_Request(a4),a0    ;address of requester struc
  1212.         move.l    _AslBase(a4),a6        ;get asl base
  1213.         CALL    AslRequest        ;do request
  1214.         tst.l    d0            ;test d0
  1215.         beq.s    cancelled        ;branch if cancelled
  1216.  
  1217.         lea    _PathBuffer(a4),a5
  1218.         move.l    _Asl_Request(a4),a0    ;address of requester struc
  1219.         move.l    rf_Dir(a0),a1        ;get dir string
  1220.         move.l    a5,a2            ;get output buffer
  1221.         moveq    #56,d0            ;set max size
  1222. copy        move.b    (a1)+,(a2)+        ;copy bytes
  1223.         dbeq    d0,copy            ;until end of string or buffer
  1224.     
  1225.         move.l    a5,d1            ;get dir name (copy)
  1226.         move.l    rf_File(a0),d2        ;get file name
  1227.         move.l    #200,d3            ;size of buffer
  1228.         move.l    _DOSBase(a4),a6        ;get dos base
  1229.         CALL    AddPart            ;create full pathname
  1230.         tst.l    d0            ;test for overflow
  1231.         beq.s    cancelled        ;branch on error
  1232.     
  1233.         moveq    #-1,d0            ;initialise count
  1234.         move.l    a5,a0            ;address of buffer    
  1235. checksize:    addq.w    #1,d0            ;decrement counter
  1236.         tst.b    0(a0,d0.w)        ;test for zero terminator
  1237.         bne.s    checksize        ;branch if not found
  1238.     
  1239.         cmpi.w    #37,d0            ;is count too large
  1240.         ble.s    sizeok            ;branch if not
  1241.         sub.w    #37,d0            ;subtract count from numchars
  1242.         add.w    d0,a0            ;add to buff adr so eostr shown
  1243. sizeok        st.b    d0            ;d0=$FF.b (Clear Z-Flag)
  1244.         rts
  1245.  
  1246. cancelled    suba.l    a0,a0            ;no filename, clear ptr
  1247.         sf.b    d0            ;d0=$00.b (Set Z-Flag)
  1248.         rts
  1249.  
  1250. *****************************************************************************
  1251. * PrintInit( )
  1252. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1253. * $Inputs:    None.
  1254. * $Outputs:    d0.l=0 if failed.. 
  1255. *
  1256. * Initializes further usage of Print( ) function.
  1257. * Gets output handle, calls AllocMem() for 127 byte output buffer, and
  1258. * RawIOInit().  Preserves all registers used.  This should be placed
  1259. * in your "opening" routine before any printf() calls.
  1260. * D0 will contain a non-zero value ( Z = 0 ) if AllocMem() was successful,
  1261. * otherwise D0 = 0 ( Z = 1 ) on return if failure.
  1262. *
  1263. * ( If PrintInit() fails, you don't need to quit.  Print( ) and can tell that 
  1264. * the allocation failed and will return without doing anything. )
  1265. ******************************************************************************
  1266.  
  1267. _PrintInit:    PUSH    d0/d1/a0/a1/a6            ;store regs on stack
  1268.         clr.l    _PrtfBase(a4)
  1269.         moveq    #127,d0                ;127 bytes
  1270.         move.l    #(MEMF_PUBLIC+MEMF_CLEAR),d1    ;of cleared public mem
  1271.         move.l    (a4),a6                ;get execbase
  1272.         CALL    AllocMem            ;allocate
  1273.         move.l    d0,_PrtfBase(a4)
  1274.         CALL    RawIOInit            ;do a raw IO init
  1275.  
  1276. _NoPrintInit:    PULL    d0/d1/a0/a1/a6            ;restore regs off stack
  1277.         tst.l    _PrtfBase(a4)
  1278.         rts
  1279.  
  1280. ******************************************************************************
  1281. * PrintClose( )
  1282. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1283. *
  1284. * If AllocMem() from PrintInit( ) was successful, this does a FreeMem()
  1285. * freeing the 127 byte output buffer.  Preserves all registers used.
  1286. * This should be placed in your "closing" routine after last printf() call.
  1287. ******************************************************************************
  1288.  
  1289. _PrintClose:    PUSH    d0/d1/a0/a1/a6
  1290.  
  1291.         tst.l    _PrtfBase(a4)
  1292.         beq.s    _NoPrintClose
  1293.         move.l    _PrtfBase(a4),a1
  1294.         moveq    #127,d0
  1295.         move.l    (a4),a6        ;get execbase
  1296.         CALL    FreeMem        ;free raw io memory
  1297.  
  1298. _NoPrintClose:    PULL    d0/d1/a0/a1/a6
  1299.         rts
  1300.  
  1301. ******************************************************************************
  1302. * Usage:  printf( FormatString DataStream )
  1303. *                   A0            A1
  1304. *
  1305. * Performs "C" language like formatting of the data stream. Where % formatting
  1306. * cmd`s are found in FormatString, they're replaced with the corresponding 
  1307. * element in the DataStream.
  1308. *
  1309. * Printf() outputs the results to the current output handle, usually the CLI.
  1310. ********************************************************************************
  1311.  
  1312. printf:        tst.l    _PrtfBase(a4)
  1313.         beq.s    _NoPrint
  1314.  
  1315.         PUSH    d0-d3/a0-a3/a6
  1316.  
  1317.         lea    PrintChar(pc),a2
  1318.         move.l    _PrtfBase(a4),a3
  1319.         move.l    (a4),a6            ;get execbase
  1320.         CALL    RawDoFmt
  1321.  
  1322.         move.l    _DOSBase(a4),a6
  1323.         move.l    _DOSOutput(a4),d1
  1324.         move.l    _PrtfBase(a4),d2
  1325.         move.l    d2,a3
  1326.         moveq    #-1,d3
  1327. .getlen        addq.l    #1,d3
  1328.         tst.b    (a3)+
  1329.         bne.s    .getlen
  1330.         CALL    Write
  1331.  
  1332.         PULL    d0-d3/a0-a3/a6
  1333. _NoPrint:    rts
  1334.  
  1335. PrintChar:    move.b    d0,(a3)+
  1336.         rts
  1337.  
  1338. *******************************************************************************
  1339. * _LoadDOSFile :- Loads an AmigaDOS file from any device into memory
  1340. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1341. * INPUTS:    a0 (.L)    = Filename
  1342. *
  1343. * OUTPUTS:    d0 (.L) = Result Code (0=File Ok,-1=Load Failed!)    
  1344. *        d1 (.L) = Length
  1345. *******************************************************************************
  1346.     
  1347. LoadDOSFile:    movem.l    d2-d7/a0-a6,-(sp)
  1348.         clr.l    ProgHandle(a4)
  1349.         clr.l    ProgBuff(a4)
  1350.         clr.l    ProgSize(a4)
  1351.  
  1352. ;-------------- Open file
  1353.         move.l    a0,d1            ;get filename
  1354.         move.l    #MODE_OLDFILE,d2
  1355.         move.l    _DOSBase(a4),a6
  1356.         jsr    _LVOOpen(a6)        ;open file
  1357.         move.l    d0,ProgHandle(a4)
  1358.         beq.s    NotFound
  1359.  
  1360. ;-------------- Get Length of file
  1361.  
  1362.         move.l    d0,d5            ;ProgHandle
  1363.         move.l    d5,d1            ;file handle
  1364.         moveq    #0,d2
  1365.         moveq    #1,d3
  1366.         move.l    _DOSBase(a4),a6
  1367.         jsr    _LVOSeek(a6)        ;seek start of file
  1368.         move.l    d5,d1            ;file handle
  1369.         moveq    #0,d2
  1370.         moveq    #-1,d3
  1371.         jsr    _LVOSeek(a6)        ;seek end of file
  1372.         move.l    d0,ProgSize(a4)
  1373.  
  1374. ;-------------- Allocate Memory for file
  1375.  
  1376.         move.l    4.w,a6            ;get execbase
  1377.         move.l    #MEMF_PUBLIC,d1        ;we want public mem
  1378.         CALL    AllocMem        ;allocate it...
  1379.         move.l    d0,ProgBuff(a4)        ;save base
  1380.         beq.b    TooBig            ;fail?
  1381.  
  1382. ;-------------- Load in whole file
  1383.                 
  1384.         move.l    ProgHandle(a4),d1
  1385.         move.l    d0,d2
  1386.         move.l    ProgSize(a4),d3
  1387.         move.l    _DOSBase(a4),a6
  1388.         jsr    _LVORead(a6)        ;read file
  1389.  
  1390. ;-------------- Close file
  1391.  
  1392. CloseFile:    move.l    ProgHandle(a4),d1
  1393.         jsr    _LVOClose(a6)        ;close file
  1394.  
  1395.         move.l    ProgSize(a4),d1    ;d1=ProgSize
  1396.         move.l    ProgBuff(a4),a1        
  1397.  
  1398.         movem.l    (sp)+,d2-d7/a0-a6
  1399.         moveq    #0,d0            ;resultcode (okay)
  1400.         rts
  1401.  
  1402. NotFound:    movem.l    (sp)+,d2-d7/a0-a6
  1403.         move.b    #-1,d0            ;file not found error-code
  1404.         rts
  1405.  
  1406. TooBig:
  1407.         move.l    ProgHandle(a4),d1
  1408.         move.l    _DOSBase(a4),a6
  1409.         jsr    _LVOClose(a6)        ;close file
  1410.         movem.l    (sp)+,d2-d7/a0-a6
  1411.         move.b    #-2,d0            ;file too big error-code
  1412. NotAlloc    rts
  1413.  
  1414. ;-------------- Free Memory for DOSFile
  1415.  
  1416. FreeDOSFile:    move.l    (AbsExecBase).w,a6    ;get execbase
  1417.         move.l    ProgBuff(a4),d0        ;ptr to our RS.Variables base
  1418.         move.l    d0,a1
  1419.         beq.s    NotAlloc
  1420.         move.l    ProgSize(a4),d0        ;no. of Bytes to free
  1421.         beq.s    NotAlloc
  1422.         jmp    _LVOFreeMem(a6)        ;free the memory
  1423.  
  1424.  
  1425.  
  1426. SaveDOSFile:    movem.l    d2-d7/a0-a6,-(sp)
  1427.         move.l    a0,d1            ;filename
  1428.         move.l    #MODE_NEWFILE,d2
  1429.         move.l    _DOSBase(a4),a6
  1430.         jsr    _LVOOpen(a6)
  1431.         move.l    d0,ProgHandle(a4)
  1432.         beq.b    _SaveError
  1433.  
  1434.         move.l    ProgHandle(a4),d1
  1435.         move.l    ProgBuff(a4),d2
  1436.         move.l    ProgSize(a4),d3
  1437.         move.l    _DOSBase(a4),a6
  1438.         jsr    _LVOWrite(a6)        ;write file
  1439.  
  1440.         move.l    ProgHandle(a4),d1
  1441.         jsr    _LVOClose(a6)        ;close file
  1442.         movem.l    (sp)+,d2-d7/a0-a6
  1443.         moveq    #0,d0
  1444.         rts
  1445.  
  1446. _SaveError:    movem.l    (sp)+,d2-d7/a0-a6
  1447. remcode        moveq    #1,d0
  1448.         rts
  1449.  
  1450. *******************************************************************************
  1451.  
  1452. MainTags:    dc.l    ASL_Height,200                ;height
  1453.         dc.l    ASL_Width,340                ;width
  1454.         dc.l    TAG_DONE                ;end of taglist
  1455.  
  1456. LoadTags:    dc.l    ASL_Hail,0                ;loadtext ptr
  1457.         dc.l    ASL_FuncFlags,FILF_PATGAD
  1458.         dc.l    TAG_DONE                ;end of taglist
  1459.  
  1460. SaveTags:    dc.l    ASL_Hail,0                ;savetext ptr
  1461.         dc.l    ASL_FuncFlags,FILF_SAVE+FILF_PATGAD
  1462.         dc.l    TAG_DONE                ;end of taglist
  1463.  
  1464. ******************************************************************************
  1465. * String & Data Variable definitions
  1466.  
  1467. LoadText:    dc.b    'Load File',0
  1468.         even
  1469. SaveText:    dc.b    'Save File',0
  1470.         even
  1471. Aslname:    dc.b    'asl.library',0                ;asl lib name
  1472.         even
  1473. Dosname:    dc.b    'dos.library',0                ;dos lib name
  1474.         even
  1475. About.Txt:    CLS    ; clear screen
  1476.         dc.b    CSI,'[0m',CSI,'[1mPPDecrypt v1.02',CSI,'[0m ',CSI,'[3m',CSI,'[33m(For Decryption of PowerPacker Encrypted Executables!) ',CSI,'[0m',LF
  1477.         dc.b    CSI,'[0mCopyright © 1994. All Rights Are Reserved.',LF
  1478.         dc.b    'Written & Developed by 2-Cool/LSd!',LF,LF
  1479.         dc.b    0
  1480.         even
  1481. Select.Txt:    dc.b    'Please Select File to Decrypt...',LF,LF
  1482.         dc.b    0
  1483.         even
  1484. ErrorType.txt    dc.b    $a,'Error: This is not a Normal PowerPacker v3.xx-v4.xx Encrypted file!',$a,$a,0
  1485.         even
  1486. ErrorAlloc.txt    dc.b    $a,'Error: Out of Memory!',$a,0
  1487.         even
  1488. ErrorMem.txt    dc.b    $a,'Error: Not enough memory to load file!',$a,0
  1489.         even
  1490. ErrorASL.txt    dc.b    $a,'Error: The "asl.library" v36+ is required!',$a,$a,0
  1491.         even
  1492. ErrorLoad.txt    dc.b    $a,'Error: Cannot open file!',$a,$a,0
  1493.         even
  1494. ErrorSave.txt    dc.b    $a,'Error: Cannot save file!',$a,$a,0
  1495.         even
  1496. NoName.txt    dc.b    "You didn`t select a valid filename!",LF,LF
  1497.         dc.b    0
  1498.         even
  1499. FilePath.fmt    dc.b    "Attempting to Load '%s'...",LF,LF
  1500.         dc.b    0
  1501.         even
  1502. Dot.Txt:    dc.b    '.',0
  1503.         even
  1504. WorkingN.Txt:    dc.b    'Crypto-Analysis in Progess...',LF,LF
  1505.         dc.b    'Pass 1..',LF,LF
  1506.         dc.b    'Compressor Used    : PowerPacker v3.xx-4.xx (Password Encrypted)',LF
  1507.         dc.b    'Decompression Code : Normal Header',LF
  1508.         dc.b    'Compression Mode   : ',0
  1509.         even
  1510. WorkingH.Txt:    dc.b    'Crypto-Analysis in Progess...',LF,LF
  1511.         dc.b    'Pass 1..',LF,LF
  1512.         dc.b    'Compressor Used    : PowerPacker v3.xx-4.xx (Password Encrypted)',LF
  1513.         dc.b    'Decompression Code : Library Header',LF
  1514.         dc.b    'Compression Mode   : ',0
  1515.         even
  1516. Length.Txt:    dc.b    'Original Length    : ',0
  1517.         even
  1518. Best.Txt:    dc.b    'Best',LF,0
  1519. VGood.Txt:    dc.b    'Very '
  1520. Good.Txt:    dc.b    'Good',LF,0
  1521. Mediocre.Txt:    dc.b    'Mediocre',LF,0
  1522. Fast.Txt:    dc.b    'Fast',LF,0
  1523. Unknown.Txt:    dc.b    'Unknown Mode!?',LF,0
  1524.         even
  1525. Pass2.Txt    dc.b    'Pass 2..',LF,0
  1526.         even
  1527. Deep.Txt:    dc.b    LF,'Deep-Mode active, Please wait..',LF,0
  1528. FilePath2.fmt    dc.b    "Attempting to Save '%s'..."
  1529. LFs.Txt:    dc.b    LF,LF
  1530.         dc.b    0
  1531.         even
  1532. Value.txt:    ds.b    16
  1533.         even
  1534. Done.Txt:    dc.b    LF
  1535.         dc.b    'Encryption key Generated, Password Cracked!!!',LF
  1536.         dc.b    'Code patched so now you can run it without any Password!',LF
  1537.         dc.b    "Use 'lsd' as Passsword for unpacking with PowerPacker!",LF,LF
  1538.         dc.b    0
  1539.         even
  1540. Done2.Txt:    dc.b    LF
  1541.         dc.b    'Encryption key Generated, Password Cracked!!!',LF
  1542.         dc.b    'File can now be unpacked with PowerPacker or by entering',LF
  1543.         dc.b    "the Password as 'lsd' at the Requester Prompt when executed.",LF,LF
  1544.         dc.b    0
  1545.         even
  1546. Args.Txt:    dc.b    'Usage   : ',CSI,'[32mPPDecrypt ',CSI,'[31m<filename>',LF
  1547.         dc.b    'Example : ',CSI,'[32mPPDecrypt ',CSI,'[31mMyProg',LF,LF
  1548.         dc.b    'You will be prompted with the asl file-requester to select the PowerPacked',LF
  1549.         dc.b    'Encrypted file to decrypt if you specify no filename.',LF,LF
  1550.         dc.b    0
  1551.